Directory

A directory-type application loads plain manifest files from .yml, .yaml, and .json files. A directory-type application may be created from the UI, CLI, or declaratively. This is the declarative syntax:

  1. apiVersion: argoproj.io/v1alpha1
  2. kind: Application
  3. metadata:
  4. name: guestbook
  5. spec:
  6. destination:
  7. namespace: default
  8. server: https://kubernetes.default.svc
  9. project: default
  10. source:
  11. path: guestbook
  12. repoURL: https://github.com/argoproj/argocd-example-apps.git
  13. targetRevision: HEAD

It’s unnecessary to explicitly add the spec.source.directory field except to add additional configuration options. Argo CD will automatically detect that the source repository/path contains plain manifest files.

Enabling Recursive Resource Detection

By default, directory applications will only include the files from the root of the configured repository/path.

To enable recursive resource detection, set the recurse option.

  1. argocd app set guestbook --directory-recurse

To do the same thing declaratively, use this syntax:

  1. apiVersion: argoproj.io/v1alpha1
  2. kind: Application
  3. spec:
  4. source:
  5. directory:
  6. recurse: true

Warning

Directory-type applications only work for plain manifest files. If Argo CD encounters Kustomize, Helm, or Jsonnet files when directory: is set, it will fail to render the manifests.

Including/Excluding Files

Including Only Certain Files

To include only certain files/directories in a directory application, set the include option. The value is a glob pattern.

For example, if you want to include only .yaml files, you can use this pattern:

  1. argocd app set guestbook --directory-include "*.yaml"

Note

It is important to quote *.yaml so that the shell does not expand the pattern before sending it to Argo CD.

It is also possible to include multiple patterns. Wrap the patterns with {} and separate them with commas. To include .yml and .yaml files, use this pattern:

  1. argocd app set guestbook --directory-include "{*.yml,*.yaml}"

To include only a certain directory, use a pattern like this:

  1. argocd app set guestbook --directory-include "some-directory/*"

To accomplish the same thing declaratively, use this syntax:

  1. apiVersion: argoproj.io/v1alpha1
  2. kind: Application
  3. spec:
  4. source:
  5. directory:
  6. include: 'some-directory/*'

Excluding Certain Files

It is possible to exclude files matching a pattern from directory applications. For example, in a repository containing some manifests and also a non-manifest YAML file, you could exclude the config file like this:

  1. argocd app set guestbook --directory-exclude "config.yaml"

It is possible to exclude more than one pattern. For example, a config file and an irrelevant directory:

  1. argocd app set guestbook --directory-exclude "{config.yaml,env-use2/*}"

If both include and exclude are specified, then the Application will include all files which match the include pattern and do not match the exclude pattern. For example, consider this source repository:

  1. config.json
  2. deployment.yaml
  3. env-use2/
  4. configmap.yaml
  5. env-usw2/
  6. configmap.yaml

To exclude config.json and the env-usw2 directory, you could use this combination of patterns:

  1. argocd app set guestbook --directory-include "*.yaml" --directory-exclude "{config.json,env-usw2/*}"

This would be the declarative syntax:

  1. apiVersion: argoproj.io/v1alpha1
  2. kind: Application
  3. spec:
  4. source:
  5. directory:
  6. exclude: '{config.json,env-usw2/*}'
  7. include: '*.yaml'